package p2;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2023-10-24
 * Time: 19:08
 */

public class exp4_1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int []arr = new int[n+1];
        int []index = new int[n+1];
        for(int i=1; i<=n; i++){
            arr[i] = sc.nextInt();
        }

        int[]box = new int[n+1];
        for(int i=0; i<n; i++){
            box[i] = 100;
        }

        //遍历物品
        for(int i=1; i<=n;i++){
            //遍历箱子
            for(int j=1; j<=n; j++){
                if(box[j] - arr[i]>=0){
                    box[j] -= arr[i];
                    index[i] = j;
                    break;
                }
            }
        }


        for (int i=1; i<=n; i++) {
            System.out.println(arr[i] + " " + index[i]);
        }
        //统计箱子个数, 找到最大值即可
        int max = 0;
        for(int j=1; j<=n; j++){
            if(index[j]>max){
                max = index[j];
            }
        }
        System.out.println(max);
    }
}
